package com.thinktank.controller;

import static com.thinktank.util.DbUtil.*;
import java.io.*;
import java.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;

import com.thinktank.vo.Board;
import com.thinktank.dao.BoardDao;

public class BoardDeleteProcessController implements Controller {
	public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		String bNo = request.getParameter("bNo");
		
		Connection con = getConnection();				
		BoardDao dao = new BoardDao(con);
		Board board = dao.getBoard(bNo);
		int result = dao.delete(bNo);
		close(con);
		
		request.setAttribute("board", board);
		
		if(result == 0) {
			return "error.jsp";
		}
		
		

		return "redirect:board.do";
	}
}
